package com.example.eduservice.controller.front;

import com.example.common.commonsutils.R;
import com.example.eduservice.entity.EduCourse;
import com.example.eduservice.entity.EduTeacher;
import com.example.eduservice.service.EduCourseService;
import com.example.eduservice.service.EduTeacherService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author:tjf
 * @Description:
 */
@RestController
@RequestMapping("/eduservice/front")
@Tag(name = "用户端主页面控制器")
public class IndexController {
    @Resource
    private EduCourseService courseService;
    @Resource
    private EduTeacherService teacherService;
    @Operation(description = "查询八科热门课程、四位名师")
    @GetMapping("/index")
    public R index(){
        // 查询热门课程
        List<EduCourse> popularCourses = courseService.queryPopularCourses();
        // 查询名师
        List<EduTeacher> popularTeachers = teacherService.queryPopularTeachers();
        return R.ok().data("courseList", popularCourses)
                        .data("teacherList", popularTeachers);
    }
}
